package map;

public class MapColoringTest implements Comparable{
    public Surplus surplus;
    private Integer constraint=0;
    private String name;
    private int num;
    public MapColoringTest(String name,int num,int constraint){
        this.name = name;
        this.num = num;
        this.constraint = constraint;
        surplus = new Surplus();
    }
    public int getNum() {
        return num;
    }
    public void setNum(int num) {
        this.num = num;
    }
    public int getConstraint() {
        return constraint;
    }
    public void setConstraint(int constraint) {
        this.constraint = constraint;
    }
    public String getName() {
        return name;
    }
    public void setName(String name) {
        this.name = name;
    }
    public String toString(){
        return "province:"+name;
    }
    public int hashCode(){
        return name.hashCode();
    }
    public boolean equals(Object o){
        MapColoringTest t = (MapColoringTest)o;
        return name.equals(t.name);
    }
    public int compareTo(Object o){
        MapColoringTest t = (MapColoringTest)o;
        if(t.getConstraint()<this.getConstraint())
            return -1;
        else if(t.getConstraint()>this.getConstraint())
            return 1;
        else if(t.surplus.getSnum()<this.surplus.getSnum())
            return 1;
        else if(t.surplus.getSnum()>this.surplus.getSnum())
            return -1;
        else return 0;
    }
}
